package mysql

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	UserId        int     `gorm:"type:int(10);not null;comment:'用户Id'"`
	ScenicId      int     `gorm:"type:int(10);not null;comment:'景点ID '"`
	RealNameId    int     `gorm:"type:int(10);not null;comment:'实名Id '"`
	OrderSn       string  `gorm:"type:varchar(50);not null;comment:'订单号'"`
	ScenicName    string  `gorm:"type:varchar(50);not null;comment:'景点名称'"`
	ScenicPrice   float64 `gorm:"type:double(10,2);not null;comment:'景点票价'"`
	ScenicAddress string  `gorm:"type:varchar(100);not null;comment:'景点地址'"`
	AdmNum        int     `gorm:"type:int(10);not null;comment:'购票数量'"`
	AdmPeopleNum  int     `gorm:"type:int(10);not null;comment:'购票人数量'"`
	SelectData    int     `gorm:"type:int(10);not null;comment:'日期选择: 1:今天 2:明天 3:后天'"`
	AdmStatus     int     `gorm:"type:int(10);not null;comment:'门票类型: 1:成人票 2:儿童票 3:特惠票'"`
	OrderStatus   int     `gorm:"type:int(10);not null;comment:'支付类型: 1:未支付 2:超时取消订单' 3:'支付完成' 4:'订单完成'"`
	InCures       int     `gorm:"type:int(10);not null;comment:'是否投保: 1:否 2:是 '"`
}

func (o *Order) Create(order *Order) error {
	return DB.Debug().Create(&order).Error
}

func (o *Order) OrderShow(id int) (result *Order, err2 error) {
	DB.Debug().Where("id = ?", id).Limit(1).Find(&result)
	return
}
